<template>
  <div id="top">
    <div class="top-box">
      <div class="top-left">
        <span class="span1"></span>
        <span class="span2"></span>
      </div>
      <input type="text" v-model="inputValue"
             placeholder="  搜索"
      @keyup.enter="toResult">
    </div>

  </div>
</template>

<script>
export default {
  name: "top",
  data(){
    return{
      inputValue:""
    }
  },
  methods:{
    toResult(){
      if(this.inputValue==''){
        alert('请输入内容')
      }else{
        //携带数据去搜索页面
        this.$router.push(`/result?q=${this.inputValue}`)
      }
    }
  }
}
</script>

<style scoped>
#top{
  width: 100%;
  height: 40px;
  /*background-color: black;*/
}
.top-box{
  position: fixed;
  display: flex;
  justify-content: space-between;
  width: 100%;
  height: 40px;
  /*background-color: #f6f6f6;*/
  background-image: linear-gradient(to left, #01204b 0%, #2a4f61 100%);
  opacity: 0.8;
  border-bottom: 1px solid #ffffff;
  /*box-shadow: 0px 0 0 1px rgba(0,0,0,.2) ;*/
  z-index: 9999;
}
  .top-left{
    display: flex;
  }
  span{
    margin: auto;
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    text-align: center;

  }
  .span1{
    margin-left: 30px;
    background: cornflowerblue;
  }
  .span2{
    margin-left: 20px;
    background-color: salmon;
  }
  input{
    margin: auto 20px;
    width: 130px;
    height: 20px;
    border-radius: 5px;
    border: 1px solid #cecece;
  }


</style>